package com.jiawa.train.business.controller.admin;


import com.jiawa.train.business.req.StationQueryReq;
import com.jiawa.train.business.req.StationSaveReq;
import com.jiawa.train.business.resp.StationQueryResp;
import com.jiawa.train.business.service.IStationService;
import com.jiawa.train.common.resp.CommonResp;
import com.jiawa.train.common.resp.PageResp;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 车站 前端控制器
 * </p>
 *
 * @author hrz
 * @since 2025-09-07
 */
@RestController
@RequestMapping("/admin/station")
@RequiredArgsConstructor
public class AdminStationController {
    private final IStationService stationService;

    @PostMapping("/save")
    public CommonResp<Object> save(@Validated @RequestBody StationSaveReq stationSaveReq) {
        stationService.save(stationSaveReq);
        return new CommonResp<>();
    }

    @GetMapping("/query-list")
    public CommonResp<PageResp<StationQueryResp>> queryList(@Validated StationQueryReq req) {
        PageResp<StationQueryResp> pa = stationService.queryList(req);
        return new CommonResp<>(pa);
    }

    @GetMapping("/query-all")
    public CommonResp<List<StationQueryResp>> queryall() {
        List<StationQueryResp> pa = stationService.queryall();
        return new CommonResp<>(pa);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        stationService.delete(id);
        return new CommonResp<>();
    }
}